#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct point{
double x,y;
point(double x=0, double y=0): x(x), y(y){}
bool leftOf(point A, point B) {return ((B.x - A.x)*(this -> y - A.y) - (B.y - A.y)*(this -> x - A.x)) > 0;}
};
int main(){
double x1, y1, x2, y2; cin>>x1>>y1>>x2>>y2;
int n; cin>>n;
int cnt = 0;
point house = {x1, y1};
point fcgm = {x2, y2};
while(n--){
double a, b, c; cin>>a>>b>>c;
if(a == 0){
if((-c/b - house.y) < 0 && (-c/b - fcgm.y) > 0 || (-c/b - house.y) > 0 && (-c/b - fcgm.y) < 0) cnt++;
}
else if(b == 0){
if((-c/a - house.x) < 0 && (-c/a - fcgm.x) > 0 || (-c/a - house.x) > 0 && (-c/a - fcgm.x) < 0) cnt++;
}
else{
ll dis1 = (a*x1)+(b*y1)+c;
ll dis2 = (a*x2)+(b*y2)+c;
if((dis1>0 && dis2<0) || (dis1<0 && dis2>0)) cnt++;
}
}
cout<<cnt<<endl;
}
202A - LLPS | 978A - Remove Duplicates |
1304A - Two Rabbits | 225A - Dice Tower |
1660D - Maximum Product Strikes Back | 1513A - Array and Peaks |
1251B - Binary Palindromes | 768B - Code For 1 |
363B - Fence | 991B - Getting an A |
246A - Buggy Sorting | 884A - Book Reading |
1180A - Alex and a Rhombus | 445A - DZY Loves Chessboard |
1372A - Omkar and Completion | 159D - Palindrome pairs |
981B - Businessmen Problems | 1668A - Direction Change |
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |